package com.ocean.admin.core.aspectj;

import com.ocean.admin.entity.SysOperLog;
import com.ocean.admin.service.ISysOperLogService;
import com.ocean.core.util.AddressUtil;
import org.springframework.stereotype.Component;

/**
 * 异步线程管理
 *
 * @author zhang
 * @since 2022/8/24
 */
@Component
public class AsyncManager {

    private static ISysOperLogService iSysOperLogService;

    public AsyncManager(ISysOperLogService iSysOperLogService) {
        AsyncManager.iSysOperLogService = iSysOperLogService;
    }

    /**
     * 将操作日志保存到数据库
     *
     * @param operLog 操作日志
     */
    public static void addOperLog(SysOperLog operLog) {
        operLog.setOperLocation(AddressUtil.getRealAddressByIp(operLog.getOperIp()));
        iSysOperLogService.save(operLog);
    }
}
